package view.components.button {
	
	/**
	 * @author Alejandro
	 */
	
	import flash.display.SimpleButton
	
	public class AbstractEstructureButton extends SimpleButton {
		
		
		/* 
		 * Define todas las propiedades predeterminadas del elemento CompleteButton
		 * de forma estatica
		 */
		
		 
		public var properties:Object = {
					x:              0,
					y:              0,
					height:         40,
					width:          160,
					useHandCursor:  true,
					text:           "",
					soundPath:      "media/button_over.mp3",
					visible:        true
					};
		public var upProperties:Object = {
					backgroundColor:"0xFFCC00",
					fontColor:"BBBBBB"
					};
		public var overProperties:Object = {
					backgroundColor:"0xCCFF00",
					fontColor:"FFFFFF"
					};
		public var downProperties:Object = {
					backgroundColor:"0x00CCFF",
					fontColor:"333333"
					};
					


		public function AbstractEstructureButton(properties_V:Object) {			
			cloneProperties(properties, properties_V);	
			clonePropertiesIfHasSet(upProperties, properties_V, "upState");		
			clonePropertiesIfHasSet(overProperties, properties_V, "overState");		
			clonePropertiesIfHasSet(downProperties, properties_V, "downState");
		}
		private function clonePropertiesIfHasSet(properties_S:Object, properties_V:Object, property:String):void {
			if (properties_V.hasOwnProperty(property)) {
				properties_V = properties_V[property];
				for (var property:String in properties_S) {
					if (properties_V.hasOwnProperty(property)) {
						properties_S[property] = properties_V[property];
					}
				}
			}
		}
		private function cloneProperties(properties_S:Object, properties_V:Object):void{
			for (var property:String in properties_S) {
				if (properties_V.hasOwnProperty(property)) {
					properties_S[property] = properties_V[property];
				}
			}
		}
		
	}
}